package com.loie.xcx.web;

import com.loie.xcx.config.DgMvcProperties;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.http.HttpStatus;

/**
 * @author zhl
 */
@ComponentScans({@ComponentScan(value = {"com.loie.xcx"})})

@Slf4j
@SpringBootApplication()
@EnableConfigurationProperties({DgMvcProperties.class})
@MapperScan("${mybatis-plus.mapper-scan:com.loie.**.mapper}")
@EnableCaching
public class DataCenterApplication {
    public static void main(String[] args) {
        SpringApplication.run(DataCenterApplication.class, args);
    }

    @Bean
    public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
        return (factory -> {
            ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/pages/index.html");
            factory.addErrorPages(errorPage404);
        });

    }

}
